import React from 'react';
// 路由使用 history模式
import {HashRouter, Route, Switch, Redirect} from 'react-router-dom';
import asyncRouter from "@/common/asyncRouter";
// 引入各个页面组件
const Home = asyncRouter(() => import('@/pages/home/index'));
const Mail = asyncRouter(() => import('@/pages/mail/index'));
const Discover = asyncRouter(() => import('@/pages/discover/community'));
const CommunityForm = asyncRouter(() => import('@/pages/communityForm/index'));
const My = asyncRouter(() => import('@/pages/my/index'));
const Chatting = asyncRouter(() => import('@/pages/chatting/index'));
const Login = asyncRouter(() => import('@/pages/login/index'));

export default () => (
  <HashRouter>
    <Switch>
      <Route path="/home" component={Home}/>
      <Route path="/mail" component={Mail}/>
      <Route path="/discover" component={Discover}/>
      <Route path="/community/form" component={CommunityForm}/>
      <Route path="/my" component={My}/>
      <Route path="/chatting/:id" component={Chatting}/>
      <Route path="/login" component={Login}/>
      <Redirect exact from="/" to="login"/>
    </Switch>
  </HashRouter>
);